<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 普通函数调用
    // var age = 19;
    var p = {
        age: 18,
        say: function() {
            console.log(this)
            console.log(this.age)
        }
    }
    var f1 = p.say
    f1()

    // 方法调用
    var p = {
        age: 18,
        say: function() {
            console.log(this)
            console.log(this.age)
        }
    }
    p.say()

    var length = 50
    var clear = function() {
        console.log(this.length)
    }
    var tom = {
        c: clear,
        length: 100
    }
    tom.c()

    // call apply 
    var f2 = function(a, b, c) {
        console.log(this)
        console.log(a + " " + b + " " + c + " ")
    }
    f2.call('1')
    f2.call(null)

    f2.call(null, 1, 2, 3)
    f2.apply(null, [1, 2, 3])


    // 箭头函数
    var p = {
        name: 'zhang',
        run: () => {
            console.log(this)
            setTimeout(() => {
                console.log(this)
            }, 100);
        },
        travel: function() {
            setTimeout(() => {
                console.log(this)
            }, 100);
        },
        say() {
            setTimeout(() => {
                console.log(this)
            }, 100);
        }
    }
    p.run()
    p.travel()
    p.say()

    let a = `aaa`
    console.log(a)

    let b = function() {
        return `c   ${a}`
    }
    console.log(b())

    var div = `< div > < p >
     < span >hhaha < /span></p > < /div>`
    console.log(div)


    let obj = {
        name: '哈哈',
        height: 165,
        grade: 3
    }

    // let {
    //     name,
    //     height,
    //     grade
    // } = obj;
    // console.log(name)
    // console.log(height)
    // console.log(grade)

    let {
        name: objname
    } = obj
    console.log(objname)

    // 函数rest
    function f3() {
        console.log(arguments.length)
    }
    f3(1, 2, 3)


    function fn(...args) {
        console.log(args instanceof Array)
        console.log(Object.prototype.toString.call(function() {}))

    }
    fn(3, 4, 5)
</script>

</html>